using System;
using System.Collections.Generic;
using System.Text;
using Shc.Sql;
using Shc.Json;
namespace CLZ.Data
{
	public static class TableRegion
	{
		public const string Table = "Region";
		public const string RegionID = "RegionID";
		public const string CityID = "CityID";
		public const string RegionName = "RegionName";
	}
	
	[Serializable]
	public class BaseRegion
		: IDbSessionEntity, IJsonClass
	{
		int m_RegionID;
		/// <summary>
        /// 县/区表ID
        /// </summary>
        public int RegionID
        {
            get { return m_RegionID; }
            set { m_RegionID = value; }
        }
		
		int? m_CityID;
		/// <summary>
        /// 城市表ID
        /// </summary>
        public int? CityID
        {
            get { return m_CityID; }
            set { m_CityID = value; }
        }
		
		string m_RegionName;
		/// <summary>
        /// 县/区名称
        /// </summary>
        public string RegionName
        {
            get { return m_RegionName; }
            set { m_RegionName = value; }
        }
		
		
		#region IDbSessionEntity Members
		public void ReadDBData(RowDataReader reader)
        {
            m_RegionID = reader[TableRegion.RegionID];
            m_CityID = reader[TableRegion.CityID];
            m_RegionName = reader[TableRegion.RegionName];
        }
		
		public void WriteDBData(RowDataWriter writer)
        {
            writer.SetPrimaryKey(TableRegion.RegionID, PrimaryKeyType.Identity, RegionID);
			writer[TableRegion.CityID] = CityID;
			writer[TableRegion.RegionName] = RegionName;
        }

        public void SetIdentityAfterInsert(DBObject idd)
        {
            m_RegionID = idd;
        }
		
		public string TableName
        {
            get { return TableRegion.Table; }
        }
		#endregion
		
		#region IJsonClass Members

        public void JsonDeSerializeObj(JsonHashTable hashToRead)
        {
             m_RegionID = hashToRead["RegionID"];
			 
             m_CityID = hashToRead["CityID"];
			 
             m_RegionName = hashToRead["RegionName"];
			 
        }

        public void JsonSerializeObj(JsonHashTable hashToFill)
        {
            hashToFill["RegionID"] = RegionID;
			 
            hashToFill["CityID"] = CityID;
			 
            hashToFill["RegionName"] = RegionName;
			 
        }

        #endregion
		
	}
}
